package com.company.genealogy.web.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.company.genealogy.web.entity.MemberSpouse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenzhixiang
 */
@Mapper
public interface MemberSpouseMapper extends BaseMapper<MemberSpouse> {
    
    /**
     * 根据成员ID查询配偶信息
     */
    @Select("SELECT * FROM tb_member_spouse WHERE member_id = #{memberId} ORDER BY sort_order")
    List<MemberSpouse> selectByMemberId(@Param("memberId") Long memberId);
    
    /**
     * 获取成员的最大配偶排序
     */
    @Select("SELECT MAX(sort_order) FROM tb_member_spouse WHERE member_id = #{memberId}")
    Integer selectMaxSortOrderByMemberId(@Param("memberId") Long memberId);
} 